<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>用户登陆</title>
	<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">  
<script>
	function myFunction() {
    var x = document.forms["myForm"]["fname"].value;
    if (x == null || x == "") {
        alert("需要输入用户名。");
        return false;
    }
    var a = document.forms["myForm"]["password"].value;
    if (a == null || a == "")
      {
    alert("请输入密码");
    return false;
    }
    var m = document.forms["myForm"]["password"].value;
        b = document.forms["myForm"]["password1"].value;
    if (b == null || b !== m )
  {
    alert("两次密码输入不一致");
    return false;
    }
    var x=document.forms["myForm"]["email"].value;
    var atpos=x.indexOf("@");
    
    var dotpos=x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
    {
        alert("不是一个有效的 e-mail 地址");
        return false;
        }
    var search_site = document.getElementById("fname").value;  
        var keyname = localStorage.getItem(search_site);  
       if(keyname!==null)
       {
           alert("用户名已使用");
           return false;
    }
  }
    function save(){  
    var site = new Object;
  //site.name=localStorage.length;

    site.keyname = document.getElementById("fname").value;
    site.sitename = document.getElementById("email").value;  
    site.siteurl = document.getElementById("password").value;
  var d=new Date();
  site.nowtime=d.toLocaleDateString();
    var str = JSON.stringify(site); // 将对象转换为字符串

    localStorage.setItem(site.keyname,str);  
 
    alert("注册成功");
  }
	function find(){  
        var search_site = document.getElementById("1name").value;  
        var str = localStorage.getItem(search_site); 
    // var site = JSON.parse(str); 

         // document.write(str.siteurl);

     if(str==null)
     {
       alert("用户名不存在");
       return false;
     }
     
     var site = JSON.parse(str);
     
     if(document.getElementById("password").value!=site.siteurl)
     {
       alert("密码不存在");
       return false;
     }
     sessionStorage.username =search_site;
     window.location.href='http://buptjiajing.gitee.io/buptsice_training_2017_2/成功3.0.html';
}
 </script>


	<style>
	p
	{text-align: center}
	h1
	{text-align: center}
	body
		{
	background-color:#b0c4de;
}
	.button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 10px 25px;
    text-align: center;
    text-decoration: none;
    font-size: 18px;
}
	</style>

</head>
<body>
	<div class="page-header">
    <h1>风流之家
        <small>Fengliu</small>
    </h1>
</div>
<div style="padding: 75px 500px 75px;">
	<form class="bs-example bs-example-form"  name="myForm" method="get">
		<div class="input-group">
			<label class="input-group-addon" >用户名</label>
			<input type="text" id="1name" class="form-control" placeholder="Your Accourt Name">
		</div>
		<br>
		<div class="input-group">
			<label class="input-group-addon" >密码</label>
			<input type="text" id="password" class="form-control" placeholder="Password">
		</div>
		<br>
		<input type="button" style="text-align:center;" onclick="find();" value="登陆">

	</form>
</div>

</body>
</html>